<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>设置</title>
    <link rel="stylesheet" href="//cdn.bootcss.com/weui/0.4.3/style/weui.min.css">
    <link rel="stylesheet" href="//cdn.bootcss.com/jquery-weui/0.8.2/css/jquery-weui.min.css">
    <link rel="stylesheet" type="text/css" href="../css/sideview.css">
	<script src="//cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
	<script src="//cdn.bootcss.com/jquery-weui/0.8.2/js/jquery-weui.min.js"></script>
	<script type="text/javascript" src="../lib/fastclick.js"></script>
	<script type="text/javascript">
		$(function() {
    		FastClick.attach(document.body);
	  	});
	</script>
</head>
<body ontouchstart>
	<div class="sideview-wrap">
		<div class="weui_cell header">
			<div class="weui_cell_hd" id="backview">
				<img src="../img/left.png">
			</div>
		    <div class="weui_cell_bd weui_cell_primary" id="setting_title">
		    	修改密码
		    </div>
		</div>
		<div class="item-wrap">
			<h4 class="change-title">请填写您的密码</h4>
			<div class="setting-input-group">
				<li class="input-item">
					<span>旧密码</span>
					<input type="text" placeholder="请输入旧密码" id="oldpwd">
				</li>
				<li class="input-item">
					<span>重设密码</span>
					<input type="text" placeholder="6-20位数字和字母的随意组合" id="newpwd">
				</li>
				<li class="input-item">
					<span>确认密码</span>
					<input type="text" placeholder="6-20位数字和字母的随意组合" id="renewpwd">
				</li>
			</div>
			<div class="weui_btn weui_btn_primary setting-btn" id="changePwd">更换手机号</div>
		</div>
	</div>
	<script type="text/javascript" src="../js/sideMenu.js"></script>
	<script type="text/javascript" src="../js/build.js"></script>
	<script type="text/javascript">
		Build.eventClick("#changePwd", function(){
			var oldpwd = $("#oldpwd").val(),
				newpwd = $("#newpwd").val(),
				renewpwd = $("#renewpwd").val();
			console.log(newpwd)
			console.log((/^[\w\W]{6,}$/.test(newpwd)));
			if(renewpwd === newpwd || newpwd !== "" || renewpwd !== ""){
				if(/^[\w\W]{6,}$/.test(newpwd)){
					Build.request({
						port: "/user/amendPassWord",
						type: "get",
						data: {
							uid: JSON.parse(sessionStorage.USER).id,
							oldPassWord: oldpwd,
							newPassWord: newpwd,
						}
					}, function(data){
						console.log(data);
					}, false);
				}else{
					$.toast("密码必须为6-20位数字和字母的随意组合!", "forbidden");
				}
			}else{
				$.toast("您输入的两次密码不相同", "forbidden");
			}
		});
	</script>
</body>
</html>